<?php
namespace ShopApi\Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;
class DiscountRefundsApiController extends AbstractRestfulController
{
    public function getList()
    {			
			
    }
    public function get($shop_id)
    {			
		header('Access-Control-Allow-Origin: *');	
		$discountTable=$this->getServiceLocator()->get('Models\Model\DiscountsFactory');
		$values=explode('-',$shop_id);
		$shop_Id=$values[0];
		$getShopDiscounts = $discountTable->getShopDiscounts($shop_Id)->toarray();
		if(count($getShopDiscounts)!=0){
			return new JsonModel(array(
				'value' 	=> 1,
				'result' 		=> $getShopDiscounts,
				
			));
		}else{
			return new JsonModel(array(
				'output' => 'fail',
				'value' => 0,
			));
		}	
    }
    public function create($data)
    {
		
    }
    public function update($order_delivery_details_id,$data)
    {
		header('Access-Control-Allow-Origin: *');	
		$orderExplode=explode('-',$order_delivery_details_id);
		$orderDeliveryDetailsTable=$this->getServiceLocator()->get('Models\Model\OrderDeliveryDetailsFactory');
		$userMedicineOrderTable=$this->getServiceLocator()->get('Models\Model\UserMedicineOrderFactory');
		$notificationTable=$this->getServiceLocator()->get('Models\Model\NotificationsFactory');
		$updateMedicineStatus = $userMedicineOrderTable->updateMedicineStatus($orderExplode[0]);
		$updateOrderdetailesStatus=$orderDeliveryDetailsTable->updateOrderdetailesStatus($orderExplode[0]);
		$deleteduplicateorderStatus=$orderDeliveryDetailsTable->deleteduplicateorderStatus($orderExplode[0]);
		$selectorderdetailes = $orderDeliveryDetailsTable->selectorderdetailes($orderExplode[0])->toArray();
		$getUserId=$userMedicineOrderTable->getUserId($orderExplode[0])->toArray();
		$sendOrderConfirmation=$notificationTable->sendReplyShopComplaint($data,'3','0',$orderExplode[1],'0','2',$getUserId[0]['user_id']);
		$sendOrderConfirmation=$notificationTable->sendcancelledComplaint($data,'3','0',$orderExplode[1],'0','1',$getUserId[0]['user_id']);
		if(count($selectorderdetailes)!=0){
			return new JsonModel(array(
				'delivered_date' 		=> $selectorderdetailes[0]['delivered_date'],
				'value'		=>	1,
			));
		}else{
			return new JsonModel(array(
				'output' 	=> 'fail',
				'value'		=>	0,
			));
		}
			
    }
    public function delete($id)
    {
       
    }
}